//
//  FRQAppVersionViewController.m
//  FRQBluetoothKit_Example
//
//  Created by admin on 2023/10/25.
//  Copyright © 2023 xuchunhai. All rights reserved.
//

#import "FRQAppVersionViewController.h"
#import "AppVersionViews.h"
@interface FRQAppVersionViewController ()
@property (nonatomic,strong) AppVersionViews *AppVersionView;
@end

@implementation FRQAppVersionViewController
- (AppVersionViews *)AppVersionView{
    if (nil==_AppVersionView) {
        _AppVersionView=skXibView(@"AppVersionViews");
        [self.view addSubview:_AppVersionView];
        [_AppVersionView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.mas_topLayoutGuide);
            make.bottom.mas_equalTo(self.mas_bottomLayoutGuide);
            make.right.left.mas_equalTo(0);
        }];
        NSString *appVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
        _AppVersionView.txtVersion.text=[NSString stringWithFormat:@"  %@",appVersion];
        @weakify(self)
        [[_AppVersionView.btnCheck rac_signalForControlEvents:(UIControlEventTouchUpInside)] subscribeNext:^(__kindof UIControl * _Nullable x) {
            @strongify(self)
            [self appVersionUpdate];
        }];
    }
    return _AppVersionView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title=@"App Version";
    self.AppVersionView.hidden=NO;
    _AppVersionView.txtVersion.enabled = NO;
}

//检测升级
-(void)appVersionUpdate{
    NSString *appVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
    NSDictionary *dic=@{@"appType":skUser.userType,@"appVersion":appVersion};
    
    [skNetTools skGETWithURL:[NSString stringWithFormat:@"%@%@",skURL,@"app/version/update"] parameters:dic cachePolicy:0 callback:^(id  _Nonnull responseObject, NSError * _Nonnull error) {
        NSLog(@"数据=%@",responseObject);
        skNetModel *model=[skNetModel mj_objectWithKeyValues:responseObject];
//        [SkToast SkToastShow:model.msg];
//        [APP.window makeToast:model.msg];
        SHOW_SUCCESS(model.msg);
        DISMISS_SVP(3);
    }];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
